package com.youngking.guns;

import com.youngking.guns.modular.weixin.CustomEventMessageHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * SpringBoot方式启动类
 *
 * @author youngking
 * @Date 2017/5/21 12:06
 */
@SpringBootApplication
public class GunsApplication {

    private final static Logger logger = LoggerFactory.getLogger(GunsApplication.class);

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext=SpringApplication.run(GunsApplication.class, args);
        CustomEventMessageHandler.setApplicationContext(applicationContext);
        logger.info("GunsApplication is success!");
    }
    @Bean
    public FilterRegistrationBean testFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean();
        registration.setFilter(new org.weixin4j.WeixinUrlFilter());
        registration.addUrlPatterns("/loginwxController/ownerCheck");
        registration.addInitParameter("paramName", "paramValue");
        registration.setName("WeixinUrl");
        registration.setOrder(1);
        return registration;
    }

}
